brute force constructive algorithms greedy implementation *1200

Please click on ads to support us..

Python Code:

n = int(input())
x = 0
y = 0
for i in range(2*n):
	a, b = map(int, input().split())
	x += a
	y += b
print(x//n, y//n)

C++ Code:

#include<bits/stdc++.h>
using namespace std;
#define		F						first
#define 	S						second
#define		PB						push_back
#define		MP			  			make_pair
typedef 	long long 					ll;
typedef 	long double					ld;
typedef 	vector<int>				 	vi;
typedef 	vector<ld>			 		vd;
typedef 	vector<ll>			 		vl;
typedef		vector<pair<int, int>>		vpii;
int main() 
{
	int tz; cin >> tz;
	ll x, y;
	ll minx = INT_MAX, miny;
	ll maxx = -INT_MAX, maxy;
	for(int t = 0; t < tz; t++)
	{
		cin >> x >> y;
		if(x < minx)
		{
			minx = x;
			miny = y;
		}
		else if(x == minx && y < miny)
		{
			miny = y;
		}
	}
	
	for(int t = 0; t < tz; t++)
	{
		cin >> x >> y;
		if(x > maxx)
		{
			maxx = x;
			maxy = y;
		}
		else if(x == maxx && y > maxy)
		{
			maxy = y;
		}
	}
	
	cout << maxx + minx << " " << maxy + miny << "\n";
	return 0;
}


Comments

Submit
0 Comments
More Questions

1041C - Coffee Break
507A - Amr and Music
1041D - Glider
1486A - Shifting Stacks
1389B - Array Walk
71B - Progress Bar
701A - Cards
545A - Toy Cars
1538E - Funny Substrings
234A - Lefthanders and Righthanders
1611D - Weights Assignment For Tree Edges
197A - Plate Game
1474A - Puzzle From the Future
6B - President's Office
1405B - Array Cancellation
431C - k-Tree
101A - Homework
1642C - Great Sequence
1523B - Lord of the Values
1406C - Link Cut Centroids
2409. Count Days Spent Together
2410. Maximum Matching of Players With Trainers
1604C - Di-visible Confusion
997A - Convert to Ones
218A - Mountain Scenery
486B - OR in Matrix
1405A - Permutation Forgery
1733A - Consecutive Sum
1733B - Rule of League
1733C - Parity Shuffle Sorting